
package view;

import java.util.ArrayList;
import controller.Controller;


/**
 * This class has the purpose of creating and returning a view object
 */

public class ViewFactory {

	/**
	 * Implementation of factory pattern to create either a SwingView, CommandLineView or a BenchMark.
	 * @param viewType contains name of view to create
	 * @param mode if true, boolean search is enabled
	 * @param c reference to Controller object
	 * @return returns a searcher object 
	 */
	public static IView createView(String viewType, boolean mode, Controller c) {
		IView view = null;

		ArrayList<String> viewNames = new ArrayList<String>();
		viewNames.add("SwingView");
		viewNames.add("CommandLineView");
		viewNames.add("BenchMarkView");

		int operator = viewNames.indexOf(viewType);

		switch (operator) {
		case 0:
			view = new SwingView(c);
			break;
		case 1:
			view = new CommandLineView(c);
			break;
		case 2:
			view = new BenchMarkView(c);
			break;

		default:
			System.out.println("You need to enter valid arguments!");
			System.out.println("\nEnter the view type you wish to use. You can choose between:");

			// Prints out a list of valid searchers
			for (int i = 0; i < viewNames.size(); i++) {
				System.out.println(viewNames.get(i));
			}
			System.exit(0);
		}
		return view;
	}

}
